import { Typography } from "antd";
import React from "react";
import {
  QuestionParagraphDefaultProps,
  QuestionParagraphPropsType,
} from "./interface";

const Component: React.FC<QuestionParagraphPropsType> = (
  props: QuestionParagraphPropsType
) => {
  const { text = "", isCenter } = {
    ...QuestionParagraphDefaultProps,
    ...props,
  };
  const textList = text.split("\n");

  return (
    <Typography.Paragraph
      style={{ textAlign: isCenter ? "center" : "start", marginBottom: "0" }}
    >
      {textList.map((t, index) => (
        <span key={index}>
          {t}
          <br />
        </span>
      ))}
    </Typography.Paragraph>
  );
};

export default Component;
